package com.vdf.sisconsolid.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

public final class SisconsolidProperties {

	private static Logger log = Logger.getLogger(SisconsolidProperties.class);

	private static Properties prop = new Properties();
	private static InputStream input = null;
	static {
		try {

			log.debug("Loading properties");
			input = (InputStream) Thread.currentThread()
					.getContextClassLoader()
					.getResourceAsStream("sisconsolid.properties");

			// load a properties file
			prop.load(input);

		} catch (IOException ex) {
			log.error("Error loading properites", ex);
		} finally {
			if (input != null) {
				try {
					input.close();
				} catch (IOException e) {
					log.error("Error closing inputstream", e);
				}
			}
		}
	}

	public static String consolidationPdfArchivesPath = "consolidationPdfArchivesPath";
	public static String jrxmlReportPath = "jrxmlReportPath";
	public static String imagesPathValue = "imagesPathValue";

	public static String getProperty(String property) {
		String propertyValue = prop.getProperty(property);
		log.debug("Property: " + property + ", Value: " + propertyValue);
		return propertyValue;
	}

	public static void main(String[] args) {
		System.out.println(getProperty(consolidationPdfArchivesPath));
	}
}
